﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Micrhard.FMCG.Server.Impl;
using System.Configuration;

namespace Microhard.GenerateProductDaySaledData
{
    class Program
    {
        private static DateTime previousExeDate = DateTime.MinValue;

        static void Main(string[] args)
        {
            while (true)
            {
                var now = DateTime.Now;
                if (previousExeDate == DateTime.MinValue)
                {
                    previousExeDate = now;
                }
                TimeSpan ts = now - previousExeDate;
                double interval = double.Parse(ConfigurationManager.AppSettings["QueryIntervalMinutes"]);
                if (ts.TotalMinutes > interval)
                {
                    Console.WriteLine("开始启动生成任务，时间:" + now + "，上次启动时间:" + previousExeDate);
                    SaleStatementImpl ssi = new SaleStatementImpl();
                    ssi.DoReport();
                    previousExeDate = now;
                    Console.WriteLine("结束任务");
                }
            }
        }
    }
}
